import request from '@/utils/request'

export function spuTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/table`,
    method: 'post',
    data: query
  })
}

export function spuLoad(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/load`,
    method: 'get',
    params: query
  })
}

export function spuSave(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/save`,
    method: 'post',
    contentType: 'json',
    data: query
  })
}

export function spuPublish(id) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/${id}/publish`,
    method: 'post'
  })
}

export function spuCancel(id) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/${id}/cancel`,
    method: 'post'
  })
}

export function spuDetail(spuId, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/${spuId}/detail`,
    method: 'post',
    data: query
  })
}

export function spuDelete(id) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/delete/${id}`,
    method: 'post'
  })
}

export function updateAttrValue(spuId, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_MALL_API}/api/mall/spu/info/base_attr/update/${spuId}`,
    method: 'post',
    contentType: 'json',
    data: query
  })
}
